import { createSlice } from '@reduxjs/toolkit'

export const loginTokenSlice = createSlice({
  name: 'loginToken',
  initialState: () => {
    const baseToken = localStorage.getItem('baseToken')
    return baseToken || ''
  },
  reducers: {
    updateLoginToken: (
      state,
      { payload = '' }: { payload: string | undefined }
    ) => {
      localStorage.setItem('baseToken', payload)
      return payload
    }
  }
})
